#include "gd32f30x.h"
#include "main.h"
#include "timer.h"
#include "gpio.h"
#include "adc.h"
#include "spi.h"
#include "can.h"


PIDREG3 piSpeed = PIDREG3_DEFAULTS;
PIDREG3 piId = PIDREG3_DEFAULTS;
PIDREG3 piIq = PIDREG3_DEFAULTS;

int main(void)	
{
	nvic_priority_group_set(NVIC_PRIGROUP_PRE2_SUB2);
	
	GpioConfig();
	TimerConfig();
	AdcConfig();
	SpiConfig();
	
	CanConfig();
	
	piSpeed.Kp = _IQ15(1.2);
	piSpeed.Ki = _IQ15(0.2);
	piSpeed.OutMax = _IQ15(1);
	piSpeed.OutMin = _IQ15(-1);
	
	piId.Kp = _IQ15(0.1);
	piId.Ki = _IQ15(0.001);
	piId.OutMax = _IQ15(1);
	piId.OutMin = _IQ15(-1);
	
	piIq.Kp = _IQ15(0.1);
	piIq.Ki = _IQ15(0.001);
	piIq.OutMax = _IQ15(1);
	piIq.OutMin = _IQ15(-1);
	
	while(1)
	{
		
	}
}
